//
//  TravelAreaStrokeTableViewCell.m
//  ToWhere
//
//  Created by dllo on 15/11/17.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "TravelAreaStrokeTableViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
#import "TravelTopicDetailsOneTableViewCell.h"

@interface TravelAreaStrokeTableViewCell ()

@property (nonatomic, retain) UIImageView *imagePic ;

@property (nonatomic, retain) UILabel *labelName;

@property (nonatomic, retain) UILabel *labelDes;

@property (nonatomic, retain) UILabel *labelPlan;

@end



@implementation TravelAreaStrokeTableViewCell

-(void)dealloc
{
    [_imagePic release];
    [_labelName release];
    [_labelPlan release];
    [_labelDes release];
    [_model release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createView];
    }
    return self;
}

-(void)createView
{
    self.imagePic = [[UIImageView alloc]init];
    
    [self addSubview:self.imagePic];
    [_imagePic release];
    
    self.labelName = [[UILabel alloc]init];
    self.labelName.font = [UIFont systemFontOfSize:19 *kWidth];
    self.labelName.textColor = [UIColor whiteColor];
    
    [self.imagePic addSubview:self.labelName];
    [_labelName release];
    
    
    self.labelPlan = [[UILabel alloc]init];
    self.labelPlan.font = [UIFont systemFontOfSize:14 *kWidth];
    self.labelPlan.textColor = [UIColor whiteColor];
    [self.imagePic addSubview:self.labelPlan];
    [_labelPlan release];
    
    
    self.labelDes = [[UILabel alloc]init];
    
    self.labelDes.font = [UIFont systemFontOfSize: 14 *kWidth];
    self.labelDes.textColor = [UIColor blackColor];
    self.labelDes.numberOfLines = 0;
    [self addSubview:self.labelDes];
    [_labelDes release];
    
  
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imagePic.frame = CGRectMake(5 *kWidth, 5*kHeight, self.frame.size.width - 10 *kWidth, 180 *kHeight);
    
    self.labelName.frame = CGRectMake(5 *kWidth, self.imagePic.frame.size.height / 3 * 2, self.imagePic.frame.size.width - 10 *kWidth, 30 *kHeight);
    self.labelPlan.frame = CGRectMake(5 *kWidth, self.labelName.frame.origin.y +self.labelName.frame.size.height, self.labelName.frame.size.width, self.labelName.frame.size.height);
    self.labelDes.frame = CGRectMake(10 * kWidth,self.imagePic.frame.size.height + 5 *kHeight +self.imagePic.frame.origin.y, self.frame.size.width - 20 *kWidth, [TravelTopicDetailsOneTableViewCell heightOfLabel:self.model.DES andTextFont:[UIFont systemFontOfSize:14 *kWidth] andTextWidth:(self.frame.size.width - 20 *kWidth)]);
  
}

-(void)setModel:(TravelStrokeModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    [self.imagePic sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"Travel_place"]];
    self.labelName.text = model.name;
                           
    self.labelDes.text = model.DES;
    
    self.labelPlan.text = [NSString stringWithFormat:@"%@天/%@个旅游地",model.plan_days_count,model.plan_nodes_count];
    
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
